Add WASM compilation and web TUI REPL for slox interpreter#1
Merged
Add WASM compilation and web TUI REPL for slox interpreter#1
Conversation
Owner
yabalaban
commented
Jan 5, 2026
- Restructure project with SloxCore library for shared interpreter code
- Add slox-wasm target for WebAssembly compilation using SwiftWasm
- Create web frontend with xterm.js for terminal-style REPL
- Add GitHub Actions workflow for automatic deployment to GitHub Pages
- Make interpreter output configurable for WASM environment
- Update native functions to be WASM-compatible (clock, print)
- Restructure project with SloxCore library for shared interpreter code - Add slox-wasm target for WebAssembly compilation using SwiftWasm - Create web frontend with xterm.js for terminal-style REPL - Add GitHub Actions workflow for automatic deployment to GitHub Pages - Make interpreter output configurable for WASM environment - Update native functions to be WASM-compatible (clock, print)
- Add .nojekyll to prevent Jekyll processing - Update workflow to use carton for SwiftWasm builds - Fix WASI and JavaScriptKit runtime URLs in app.js
- Use SwiftWasm 5.9.2 release (verified working URL) - Use carton 1.1.3 release - Add debug output to workflow steps - Fix tar strip-components for SwiftWasm extraction
Change from esm.sh to unpkg.com CDN which provides direct ES module access for the WASI shim and JavaScriptKit Swift runtime dependencies.
Instead of relying on CDN imports which were failing, bundle custom implementations of: - wasi-loader.js: Browser WASI shim for SwiftWasm - swift-runtime.js: JavaScriptKit Swift runtime for browser This avoids dependency on external CDNs and ensures compatibility.
…llback The JavaScript callback passed to initInterpreter is a function, which maps to JSFunction in JavaScriptKit, not JSObject. Using args[0].object returned nil causing the guard to fail or force unwrap to crash. Also store JSClosures globally to prevent garbage collection.
- Add Driver.runRepl() that returns evaluation result - Add Interpreter.interpretRepl() to capture last expression value - Update WASM execute to use runRepl and output the result - Add tests for REPL-style evaluation Now every REPL input shows its result (nil for declarations/statements)
- Add getGlobals() and reset() methods to Driver - Expose new methods via WASM to JavaScript - Handle % prefixed commands in app.js - Update help/manpage with magic commands section - Add tests for magic command support methods
- Add getBuildTime() to WASM API, show in startup message - Remove all debug console.log statements - Add multiline input support (Python REPL style): - Continuation prompt "..." for incomplete input - Detects unclosed braces, parens, strings - Add cursor navigation: - Left/Right arrows move by character - Ctrl+Left/Right move by word - Home/End jump to start/end of line - Ctrl+A/E for start/end (readline style) - Ctrl+W deletes word backward - Delete key support - Update help page with new keybindings
- Add comprehensive CLAUDE.md project guide for AI assistants - Add inline comments and JSDoc documentation to app.js - Add MARK sections and documentation to Swift files - Improve code organization with section headers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.